Completed
Push — master ( 612930...f93d09 )
by Andres
29s
created

gulp.task(ꞌgenerate_unlocksꞌ)   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
c 0
b 0
f 0
nc 1
dl 0
loc 3
rs 10
nop 0
1
/*jslint node: true */
2
/*jslint esversion: 6 */
3
'use strict';
4
5
// Include gulp
6
let gulp = require('gulp');
7
let del = require('del');
8
let runSequence = require('run-sequence');
9
let uglifyes = require('uglify-es');
10
let composer = require('gulp-uglify/composer');
11
12
// Include plugins
13
let plugins = require('gulp-load-plugins')();
14
15
let Server = require('karma').Server;
16
let ugly = composer(uglifyes, console);
17
18
// unit test
19
gulp.task('karma', function (done) {
20
  new Server({
21
    configFile: __dirname + '/test/unit/karma.conf.js',
0 ignored issues
show
Compatibility introduced by
Consider using the path module for constructing paths since they are otherwise not cross-OS compatible.
Loading history...
22
    singleRun: true
23
  }, done).start();
24
});
25
26
gulp.task('codecov', function() {
27
  return gulp
28
    .src(['test/unit/coverage/**/lcov.info'], { read: false })
29
    .pipe(plugins.codeclimateReporter({ token: '8e959350aa2fde657bbdd472964d5b2bdbb7d2ba10b8f6137865f2c241ecc86e' }))
30
  ;
31
});
32
33
// e2e test
34
gulp.task('connect', function() {
35
  return plugins.connect.server({
36
    root: 'build/',
37
    port: 9000
38
  });
39
});
40
41
gulp.task('webdriver_update', plugins.protractor.webdriver_update_specific({
42
	browsers: ['ignore_ssl']
43
}));
44
45
gulp.task('protractor', ['connect', 'webdriver_update'], function() {
46
  return gulp.src(['test/integration/spec/**.js'], { read: false })
47
    .pipe(plugins.protractor.protractor({
48
        configFile: 'test/integration/protractor.conf.js'
49
    }))
50
    .on('error', function(e) { throw e; });
51
  });
52
53
gulp.task('disconnect', function() {
54
  return plugins.connect.serverClose();
55
});
56
57
// clean
58
gulp.task('clean',function(){
59
  return del(['dist','build']);
60
});
61
62
// dist
63
64
gulp.task('htmlmin', function() {
65
  return gulp.src('build/**/*.html')
66
    .pipe(plugins.htmlmin({collapseWhitespace: true}))
67
    .pipe(gulp.dest('dist/'));
68
});
69
70
gulp.task('uglify', function() {
71
  return gulp.src('build/scripts/app.min.js')
72
    .pipe(ugly())
73
    .pipe(gulp.dest('dist/scripts'));
74
});
75
76
gulp.task('cleanCss', function() {
77
  return gulp.src('build/**/*.css')
78
    .pipe(plugins.cleanCss())
79
    .pipe(gulp.dest('dist/'));
80
});
81
82
gulp.task('minify', ['uglify', 'htmlmin', 'cleanCss']);
83
84
// FIXME can we do this with a parametric task?
85
gulp.task('copy-lib-dist', function() {
86
  return gulp.src('bower_components/**')
87
    .pipe(gulp.dest('dist/bower_components'));
88
});
89
90
// dependencies
91
92
gulp.task('bower', function() {
93
  return plugins.bower();
94
});
95
96
// copy
97
gulp.task('copy-js', function() {
98
  return gulp.src('src/scripts/**')
99
    .pipe(gulp.dest('build/scripts'));
100
});
101
102
gulp.task('copy-data', function() {
103
  return gulp.src('src/data/**')
104
    .pipe(gulp.dest('build/data'));
105
});
106
107
gulp.task('copy-html', function() {
108
  return gulp.src('src/html/**')
109
    .pipe(gulp.dest('build/'));
110
});
111
112
gulp.task('copy-css', function() {
113
  return gulp.src('src/styles/**')
114
    .pipe(gulp.dest('build/styles'));
115
});
116
117
gulp.task('copy-lib', function() {
118
  return gulp.src('bower_components/**')
119
    .pipe(gulp.dest('build/bower_components'));
120
});
121
122
gulp.task('copy-build', ['copy-js', 'copy-data', 'copy-html',
123
                        'copy-css', 'copy-lib']);
124
125
// build
126
127
gulp.task('populate_player', function() {
128
  return plugins.run('node build_scripts/populate_player.js',{silent:true}).exec();
129
});
130
131
gulp.task('populate_data', function() {
132
  return plugins.run('node build_scripts/populate_data.js',{silent:true}).exec();
133
});
134
135
gulp.task('generate_isotopes', function() {
136
  return plugins.run('node build_scripts/generate_isotopes.js',{silent:true}).exec();
137
});
138
139
gulp.task('generate_resource_matrix', function() {
140
  return plugins.run('node build_scripts/generate_resource_matrix.js',{silent:true}).exec();
141
});
142
143
gulp.task('generate_decay', function() {
144
  return plugins.run('node build_scripts/generate_decay.js',{silent:true}).exec();
145
});
146
147
gulp.task('generate_ions', function() {
148
  return plugins.run('node build_scripts/generate_ions.js',{silent:true}).exec();
149
});
150
151
gulp.task('generate_reactions', function() {
152
  return plugins.run('node build_scripts/generate_reactions.js',{silent:true}).exec();
153
});
154
155
gulp.task('generate_antimatter', function() {
156
  return plugins.run('node build_scripts/generate_antimatter.js',{silent:true}).exec();
157
});
158
159
gulp.task('generate_achievements', function() {
160
  return plugins.run('node build_scripts/generate_achievements.js',{silent:true}).exec();
161
});
162
163
gulp.task('generate_unlocks', function() {
164
  return plugins.run('node build_scripts/generate_unlocks.js',{silent:true}).exec();
165
});
166
167
gulp.task('generate_achievement_functions', function() {
168
  return plugins.run('node build_scripts/generate_achievement_functions.js',{silent:false}).exec();
169
});
170
171
gulp.task('generate_upgrades', function() {
172
  return plugins.run('node build_scripts/generate_upgrades.js',{silent:false}).exec();
173
});
174
175
gulp.task('generate_exotic_upgrades', function() {
176
  return plugins.run('node build_scripts/generate_exotic_upgrades.js',{silent:false}).exec();
177
});
178
179
gulp.task('generate_upgrade_functions', function() {
180
  return plugins.run('node build_scripts/generate_upgrade_functions.js',{silent:true}).exec();
181
});
182
183
gulp.task('generate_element_slot', function() {
184
  return plugins.run('node build_scripts/generate_element_slot.js',{silent:true}).exec();
185
});
186
187
gulp.task('sort_resources', function() {
188
  return plugins.run('node build_scripts/sort_resources.js',{silent:true}).exec();
189
});
190
191
gulp.task('concat', function() {
192
  return gulp.src(['build/scripts/modules/module.js',
193
    'build/scripts/**/*!(module.js)'])
194
    .pipe(plugins.concat('app.min.js'))
195
    .pipe(gulp.dest('build/scripts'));
196
});
197
198
// public tasks
199
gulp.task('build', function(callback) {
200
  runSequence(
201
    'clean',
202
    'bower',
203
    'copy-build',
204
    'generate_isotopes',
205
    'generate_resource_matrix',
206
    'generate_ions',
207
    'generate_decay',
208
    'generate_reactions',
209
    'generate_antimatter',
210
    'generate_achievements',
211
    'generate_unlocks',
212
    'generate_upgrades',
213
    'generate_exotic_upgrades',
214
    'generate_achievement_functions',
215
    'generate_upgrade_functions',
216
    'generate_element_slot',
217
    'sort_resources',
218
    'populate_player',
219
    'populate_data',
220
    'concat',
221
    callback);
222
});
223
224
gulp.task('build-unit-test', function(callback) {
225
  runSequence('build', 'karma', callback);
226
});
227
228
gulp.task('dist', function(callback) {
229
  runSequence('build', 'minify', 'copy-lib-dist', callback);
230
});
231
232
gulp.task('unit-test', function(callback) {
233
  runSequence('dist', 'karma', 'codecov', callback);
234
});
235
236
gulp.task('e2e-test', function(callback) {
237
  runSequence('dist', 'protractor', 'disconnect',
238
              callback);
239
});
240
241
gulp.task('test', ['unit-test', 'e2e-test']);
242